package com.ch06.ex04;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.charset.Charset;

/**
 * Created by zc on 2016/3/16.
 */
public class SlicedMain2 {

    public static void main(String[] args){
        Charset utf8 = Charset.forName("UTF-8");
        ByteBuf buf = Unpooled.copiedBuffer("Netty in Action rocks!", utf8);

        ByteBuf copy = buf.copy(0, 14);
        System.out.println(copy.toString(utf8));

        buf.setByte(0, (byte)'J');
        boolean rs = buf.getByte(0) == copy.getByte(0);
        System.out.println(rs);
    }
}
